/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gw.reportbuilder.util;

import gw.reportbuilder.nucleo.Conexao;
import gw.reportbuilder.nucleo.excecao.ExcecaoConexao;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author Sostenes
 */
public class ConnectionUtil {

    public static Connection getConnection() throws IOException {
  
        try {
            return Conexao.getConnection();
        } catch (ExcecaoConexao ex) {
            
            throw new RuntimeException(ex);
        }
    }

    public static void cleanup(Connection conn, Statement stmt, ResultSet rs) {


        try {

            if (rs != null) {
                rs.close();
            }
            if (stmt != null) {
                stmt.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            
        }
    }
}
